package com.dmbjz.rpc.controller;


import com.dmbjz.rpc.service.WeatherService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Mono;

@RestController
public class WeatherController {

    @Resource
    private WeatherService weatherService;


    //使用 WebClient 方式请求
    @GetMapping("weather")
    public Mono<String> weather(@RequestParam String city) {
        return weatherService.weather(city);
    }


    //使用 HttpInterface 方式请求
    @GetMapping("weather2")
    public Mono<String> weather2(@RequestParam String city) throws InterruptedException {
        return weatherService.weather2(city);
    }

}
